package com.ge.healthcare.autosc.common.createrfs.test;

import com.ge.med.service.eds.caseAPI.ICase;
import com.ge.med.service.eds.caseAPI.vo.AssistCaseCreateResponse;
import com.ge.med.service.eds.caseAPI.vo.ICaseCreateRequestVO;
import com.ge.med.service.eds.caseAPI.vo.ICaseCreateResponseVO;
import com.ge.med.service.eds.caseAPI.vo.ICaseListRequestVO;
import com.ge.med.service.eds.caseAPI.vo.ICaseListResponseVO;
import com.ge.med.service.eds.commons.DataException;
import com.ge.med.service.eds.commons.ResourceException;

public class MockICase implements ICase{

    private boolean throwDataException;
    private boolean returnNull;
    private RuntimeException runtimeEx;
    private boolean throwResourceException;
    private ICaseListResponseVO[] iCaseList = new ICaseListResponseVO[0];
    private boolean throwDataExceptionDuringSearch;
    private boolean throwResourceExceptionDuringSearch;
    private String errorMessageToReturn;
    

    public void asynchronousCreate(ICaseCreateRequestVO arg0, int arg1) throws ResourceException, DataException {
    }

    public ICaseCreateResponseVO createCase(ICaseCreateRequestVO arg0) throws DataException, ResourceException {
        if (throwDataException){
            throw new DataException(0, "Test DataException");
        }
        if (throwResourceException){
            throw new ResourceException(0, "Test ResourceException");
        }
        if (returnNull){
            return null;
        }
        
        if (runtimeEx != null){
            throw runtimeEx;
        }
        AssistCaseCreateResponse resp = new AssistCaseCreateResponse();
        
        if (errorMessageToReturn != null){
            resp.setError(errorMessageToReturn);
        }else{
            resp.setAssistNo(123456);            
        }
 

        return resp;
    }

    public ICaseListResponseVO[] searchByCaseListInput(ICaseListRequestVO arg0) throws DataException, ResourceException {
        if (throwDataExceptionDuringSearch){
            throw new DataException(0, "Test DataException");
        }
        if (throwResourceExceptionDuringSearch){
            throw new ResourceException(0, "Test ResourceException");
        }
        
        
        return iCaseList;
    }

    public void setThrowResourceExceptionDuringSearch(boolean b) {
        throwResourceExceptionDuringSearch = b;
    }


    public void setThrowDataExceptionDuringSearch(boolean b) {
        throwDataExceptionDuringSearch = b;
    }
    
    
    public void setThrowDataException(boolean b) {
        throwDataException = b;
        
    }

    public void setReturnNull(boolean b) {
        returnNull = b;
    }

    public void setExceptionToThrow(RuntimeException ex) {
        runtimeEx = ex;
    }

    public void setThrowResourceException(boolean b) {
        throwResourceException = b;
        
    }
    public void setErrorMessageToReturn(String errorMessageToReturn) {
        this.errorMessageToReturn = errorMessageToReturn;
    }

    public void setICaseList(ICaseListResponseVO[] list) {
        iCaseList = list;
    }

}
